package oving6;


import java.util.ArrayList;

public class AccountOverview {
	private ArrayList <Account>accounts ;
	public AccountOverview(){
		accounts = new ArrayList<Account>();
	}
	public int getAccountCount(){
		return accounts.size();
	}
	public Account getAccount(int numb){
		return accounts.get(numb);
	}
	public void addAccount(Account ac){
		if(!accounts.contains(ac)){
			accounts.add(ac);
		}
	}
	public int getTotalBalance(){
		int balance=0;
		for(int i=0;i<getAccountCount();i++){
			balance+=accounts.get(i).getBalance();
		}
		return balance;
	}
	public int getTotalCredit(){
		int credit=0;
		for(int i=0;i<getAccountCount();i++){
			credit+=accounts.get(i).getCredit();
		}
		return credit;
	}
	public int getTotalFees(){
		int fees=0;
		for(int i=0;i<getAccountCount();i++){
			if(accounts.get(i) instanceof CreditAccount){
				CreditAccount c=(CreditAccount)accounts.get(i);
				fees+=c.getFees();
			}
		}
		return fees;
	}
}
